package modelCollection;

import java.util.TreeMap;
import java.util.Vector;

import dataCollection.AbstractDetailTreeAlgorithms;
import dataCollection.Dice;
import dataCollection.Die;
import dataCollection.InvalidDiceException;
import dataCollection.Trait;
import dataCollection.AbstractDetail;
import dataCollection.Tree;

public class Character {
  
  //Trait to Dice
  private TreeMap<String, Dice> traits_map_;
  
  public Character(Tree<AbstractDetail> ability_tree) {
    traits_map_ = new TreeMap<String, Dice>();
    Vector<Trait> traits = AbstractDetailTreeAlgorithms.getAllTraits(ability_tree);;
    for(Trait trait : traits) {
      traits_map_.put(trait.getName(), null);
    }
  }
  
  public void printChar() {
    for(String key : traits_map_.keySet()) {
      System.out.print("Trait: " + key);
      if(traits_map_.get(key) != null)
        System.out.println(" - Dice: " + traits_map_.get(key).toString());
      else 
        System.out.println(" - Dice: NONE");
    }
  }
  
  public void setTrait(String key, Dice d) {
    if(!traits_map_.containsKey(key)) return;
    traits_map_.put(key, d);
  }
  
  public Dice getTraitDice(String key) {
    if(!traits_map_.containsKey(key)) return null;
    return traits_map_.get(key);
  }
  
  public void removeTraitDice(String key) {
    if(!traits_map_.containsKey(key)) return;
    traits_map_.put(key, null);
  }
}
